#pragma once
#include "common.h"
#include "trader.h"
#include "market.h"

class Manager
{
	typedef Manager This;
protected:
	boost::property_tree::ptree cfg_;
	boost::property_tree::ptree info_;
	bool load_info();
	void save_info();
public:

	static Manager& Inst()
	{
		static Manager s_inst;
		return s_inst;
	}

	Manager();

	inline boost::property_tree::ptree& cfg() { return cfg_; }
	inline const boost::property_tree::ptree& cfg() const { return cfg_; }
	inline boost::property_tree::ptree& info() { return info_; }
	inline const boost::property_tree::ptree& info() const { return info_; }

	bool init(const char* xml, int xmlflag);
	bool start();
	void run();
	void stop(size_t flags);

	void on_normal(bool new_trading_day);

	void begin_new_tradingday();
	void init_new_tradingday();
	void end_new_tradingday();
};
